package com.linglan;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

@SpringBootApplication
public class LingLanApplication {

    public static void main(String[] args) throws IOException {
        String fileName = "/config.properties";
        Object configFile = System.getProperties().get("server-config-path");
        String file = null;
        if (configFile == null) {
            file = "/data/linglan/" + fileName;
        } else {
            file = configFile.toString() + fileName;
        }

        init(file);
        SpringApplication.run(LingLanApplication.class, args);
    }

    public static void init(String filename) throws IOException {
        System.getProperties().load(Files.newInputStream(Paths.get(filename)));
    }

}
